package com.woniu.supermarket.web;

import com.woniu.supermarket.entity.OutboundCheck;
import com.woniu.supermarket.result.ResultResponse;
import com.woniu.supermarket.service.IOutboundCheckService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("OutboundCheck")
@Api(value = "出库审核操作")
public class OutboundCheckController {

    @Autowired
    IOutboundCheckService iOutboundCheckService;

    @RequestMapping("/findOutboundByCode")
    @ApiOperation(value = "通过出库单号查询审核信息")
    public ResultResponse<List<OutboundCheck>> findOutboundByCode(@RequestParam("outboundNumber") String code){
        ResultResponse<List<OutboundCheck>> result = null;
        try {
            List<OutboundCheck> lists = iOutboundCheckService.findOutboundCheckByCode(code);
            result = new ResultResponse<>(200,"查询出库审核信息成功",lists);
        }catch (RuntimeException e){
            e.printStackTrace();
            result = new ResultResponse<>(201,"查询出库审核信息失败");
        }
        return result;
    }
}
